home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / exec / viewcupresults.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  5KB  |  205 lines

  1. /* ***********************************************************************
  2.  
  3.    CUP RESULTS PROGRAM FOR FOOTBALL REXX SUITE
  4.   ---------------------------------------------
  5.                    Copyright  Mark Naughton 1997
  6.  
  7.  
  8. Version    Date     History
  9. --------------------------------------------------------------------------
  10.  1.0       011197   First release.
  11.            151297   Added routine to improve on the round names. Tidied
  12.                     display. Improved method that read the file and
  13.                     formatted it - smaller.
  14.            260898   Amended bettername() for 1 or 2 legs.
  15.            250899   Added error msg to file check.
  16.  1.1       030999   Converted to use locale. Some error messages, before
  17.                     reading the locale, will still be in English.
  18.                     English language still needs to appear in the datafiles
  19.                     for processing by Football.
  20.  
  21. **************************************************************************
  22.  
  23. Procedure
  24. ---------
  25.  
  26. 1. Check files exist.
  27. 2. Open file and print all lines without '*' with the exception of
  28.    the league name which is underlined; possibly dates as well.
  29. 3. Also reformat "*Round" from the file into a more readable look.
  30. 3. Close file and exit.
  31.  
  32. ************************************************************************** */
  33. parse arg league_file
  34.  
  35. version     = 1
  36. league_file = "Data/" || league_file
  37. input_file  = '.scf'
  38. separator   = '*'
  39. separator2  = '#'
  40.  
  41.  
  42. if open(datafile,"Data/Football.locale",'r') then do
  43.    line = readln(datafile)
  44.    locdir = strip(line)
  45.    close(datafile)
  46. end
  47. else do
  48.    say
  49.    say "ERROR :    (ViewCupResults)"
  50.    say
  51.    say "Cannot read 'Data/Football.locale' for the locale settings."
  52.    exit
  53. end
  54.  
  55. dcupdir = locdir"Football.locale_cup"
  56. locdir = locdir"Exec/ViewCupResults.data"
  57.  
  58. if open(datafile,"ENV:FootballRXPath",'r') then do
  59.    line = readln(datafile)
  60.    rxdir = strip(line)
  61.    close(datafile)
  62. end
  63. else
  64.    rxdir = "SYS:Rexxc/"
  65.  
  66. if exists(locdir) > 0 then do
  67.   address command rxdir'rx 'locdir
  68.   VarCount = getclip('VarCount')
  69.   do i = 1 to VarCount
  70.     interpret getclip('var.'i)
  71.   end
  72. end
  73. else do
  74.    say
  75.    say "ERROR :    (ViewCupResults)"
  76.    say
  77.    say "Cannot find '"locdir"' to read locale settings."
  78.    exit
  79. end
  80.  
  81. if exists(dcupdir) > 0 then do
  82.   address command rxdir'rx 'dcupdir
  83.   VarCount = getclip('VarCount')
  84.   do i = 1 to VarCount
  85.     interpret getclip('var.'i)
  86.   end
  87. end
  88. else do
  89.    say
  90.    say "ERROR :    (ViewCupResults)"
  91.    say
  92.    say "Cannot find '"dcupdir"' to read cup locale settings."
  93.    exit
  94. end
  95.  
  96. if exists(league_file || input_file) = 0 then do
  97.    say
  98.    say vcr_error
  99.    say
  100.    say vcr_t2"'"league_file||input_file"'."
  101.    exit
  102. end
  103.  
  104. if open(datafile,league_file || input_file,'r') then do
  105.    say
  106.    say center(vcr_t5,78)
  107.    say
  108.    say center(vcr_t6,78)
  109.    say
  110.    do while ~eof(datafile)
  111.       line = readln(datafile)
  112.       if pos(separator,line) = 0 then do
  113.          if pos(separator2,line) > 0 then do
  114.             if pos("#Score After Extra Time",line) > 0 then
  115.                line = overlay("--"left(cup_saet,25," "),line,1,25)
  116.             if pos("#Penalties",line) > 0 then
  117.                line = overlay("--"left(strip(fc_t8),25," "),line,1,25)
  118.             if pos("#1st Leg",line) > 0 then
  119.                line = overlay("--"left(cum_t32,25," "),line,1,25)
  120.          end
  121.          say line
  122.       end
  123.       else do
  124.          if pos("**",line) > 0 then do
  125.             parse var line "** "cupname
  126.             say center(cupname,78)
  127.             say "-------------------------------------------------------------------------------"
  128.          end
  129.          else do
  130.             if pos("*Round=",line) > 0 then do
  131.                if pos(" Leg",line) > 0 then do
  132.                   k = pos(" Leg",line)
  133.                   roundname = bettername(substr(line,8,5),substr(line,k-1,6))
  134.                end
  135.                else
  136.                   roundname = bettername(substr(line,8,5),cs_t29)
  137.                say
  138.                say trim(roundname)
  139.                uline = ''
  140.                do i=1 to length(trim(roundname))
  141.                   uline = insert('-',uline,i,1)
  142.                end
  143.                say strip(uline)
  144.             end
  145.          end
  146.       end
  147.    end
  148.    say "-------------------------------------------------------------------------------"
  149.    close(datafile)
  150. end
  151. else do
  152.    say
  153.    say vcr_error
  154.    say
  155.    say vcr_t3"'"league_file||input_file"'"vcr_t4
  156. end
  157.  
  158. exit
  159.  
  160. /* Routine ----------------------------------------------------------- */
  161.  
  162. bettername:
  163. parse arg crn,legless
  164.  
  165. trdn = substr(crn,1,1)
  166. if datatype(trdn,'n') = 1 then do
  167.    if pos("Replay",crn) > 0 then
  168.       trn = strip(word(crn,1))" "cs_t28" "cs_t31
  169.    else do
  170.       parse var crn roundno" " .
  171.       trn = strip(crn)" "cs_t28
  172.    end
  173. end
  174. else do
  175.    if pos("Final",crn) > 0 then do
  176.       if pos("Replay",crn) > 0 then
  177.          trn = cs_t30" "cs_t31
  178.       else
  179.          trn = cs_t30
  180.    end
  181.    if pos("Semi",crn) > 0 then do
  182.       if pos("Replay",crn) > 0 then
  183.          trn = cs_t32" "cs_t31
  184.       else
  185.          trn = cs_t33
  186.    end
  187.    if pos("Quart",crn) > 0 then do
  188.       if pos("Replay",crn) > 0 then
  189.          trn = cs_t34" "cs_t31
  190.       else
  191.          trn = cs_t35
  192.    end
  193.    if pos("Third",crn) > 0 then do
  194.       trn = cs_t36
  195.    end
  196. end
  197.  
  198. if pos("1 Leg",legless) > 0 then
  199.    trn = trn"  ("cum_t32")"
  200. if pos("2 Legs",legless) > 0 then
  201.    trn = trn"  ("cum_t33")"
  202.  
  203. return trn
  204.  
  205. /* ------------------------------------------------------------------- */